<script>
	import { beforeUpdate } from 'svelte'
	import { createEventDispatcher } from 'svelte';
  export let lang
	const dispatch = createEventDispatcher();
	let work
	let cv
	
  beforeUpdate( () => {
		switch (lang){
		// 英文
			case 'en':
				work = 'My Works'
				cv = 'My Resume'
				break
			// 中文和未定义语言，一定要放在最后
			case 'zh':
			default:
				work = '我的作品'
				cv = '我的简历'
				break
		}
  })

	function cvClicked(e) {
		dispatch('cvClicked', {
			text: 'Hello!'
		});
	}
</script>

<nav>
  <!-- svelte-ignore a11y-invalid-attribute -->
  <!-- <button>{work}</button> -->
  <!-- svelte-ignore a11y-invalid-attribute -->
  <button on:click={cvClicked}>{cv}</button>
</nav>